﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversityCourses.Models;

namespace UniversityCourses.Tests.Models
{
    class InMemoryUniversityCourses : IUniversityCoursesRepository
    {
        private List<Course> courseEntities = new List<Course>();
        private List<StudentCourse> studentCourseEntities = new List<StudentCourse>();
        private List<Student> studentsEntities = new List<Student>();

        public void DeleteCourse(int id)
        {
            Course course = this.courseEntities.FirstOrDefault(p => p.Id == id);
            if (course != null)
                this.courseEntities.Remove(course);
        }

        public void CreateCourse(Course course)
        {
            this.courseEntities.Add(course);
        }

        public IEnumerable<Course> GetAllCourses()
        {
            return this.courseEntities;
        }

        public IEnumerable<int> GetCoursesByStudentEmail(string email)
        {
            Student student = studentsEntities.FirstOrDefault(p => p.Email.ToList() == email.ToList());
            return studentCourseEntities.Where(p => p.StudentId == student.UserId).Select(p => p.CourseId);
        }

        public Course GetCoursesById(int id)
        {
            return courseEntities.FirstOrDefault(p => p.Id == id);
        }



        public void UpdateCourse(Course course)
        {
            throw new NotImplementedException();
        }



        public void Register(int id, string studentEmail)
        {
            throw new NotImplementedException();
        }

        public bool StudentExists(string email)
        {
            throw new NotImplementedException();
        }

        public void CreateStudent(string email, string provider, string providerUserId)
        {
            throw new NotImplementedException();
        }

        public Student GetStudentByEmail(string email)
        {
            throw new NotImplementedException();
        }

    }
}
